package com.gxa.customer.controller;

import com.gxa.common.commons.JsonResult;
import com.gxa.common.commons.R;
import com.gxa.common.pojo.MerchantSea;
import com.gxa.customer.service.MerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/customer/merchant")
public class MerchantSeaController {

    @Autowired
    private MerchantService merchantService;

    //新建商海信息
    @PostMapping(value = "/addMerchant")
    public R addMerchant(MerchantSea merchantSea){
        return merchantService.addMerchant(merchantSea);
    }

    //删除具体商海
    @PostMapping(value = "/delMerchant")
    public R delMerchant(Long merchantSeaTableId){
        return merchantService.delMerchant(merchantSeaTableId);
    }

    //修改商海上下架状态
    @PostMapping(value = "/updateStatus")
    public R updateStatus(MerchantSea merchantSea){
        return merchantService.updateStatus(merchantSea);
    }

    //编辑具体商海信息
    @PostMapping(value = "/updateMerchant")
    public R updateMerchant(MerchantSea merchantSea){
        return merchantService.updateMerchant(merchantSea);
    }

    //查询所有商海信息（分页）
    @GetMapping(value = "/selectAllMerchant")
    public JsonResult selectAllMerchant(Integer current, Integer limit){
        return merchantService.selectAllMerchant(current,limit);
    }

    //查询具体商海详情
    @GetMapping(value = "/selectMerchantById")
    public R selectMerchantById(Long merchantSeaTableId){
        return merchantService.selectMerchantById(merchantSeaTableId);
    }

    //查询国家对应的商海信息（分页）
    @GetMapping(value = "/selectMerchantByCountryId")
    public JsonResult selectMerchantByCountryId(Long countryId, Integer current, Integer limit) {
        return merchantService.selectMerchantByCountryId(countryId,current,limit);
    }

    //根据国家和地区查询商海信息（分页）
    @GetMapping(value = "/selectMerchantByCountryIdAndProvinceId")
    public JsonResult selectMerchantByCountryIdAndProvinceId(Long countryId, Long provinceId, Integer current, Integer limit){
        return merchantService.selectMerchantByCountryIdAndProvinceId(countryId, provinceId, current, limit);
    }

    //根据行业类型查询商海信息(分页)
    @GetMapping(value = "/selectMerchantByIndustryId")
    public JsonResult selectMerchantByIndustryId(Long industryId, Integer current, Integer limit) {
        return merchantService.selectMerchantByIndustryId(industryId, current, limit);
    }

    //根据商海id查询商海对应的所有申请用户(分页)
    @GetMapping(value = "/selectAllUserByMerchantId")
    public JsonResult selectAllUserByMerchantId(Long merchantSeaTableId, Integer current, Integer limit) {
        return merchantService.selectAllUserByMerchantId(merchantSeaTableId,current,limit);
    }

    //查询所有商海信息（按照浏览量倒序排序-app）
    @GetMapping(value = "/selectAllMerchantByPageView")
    public R selectAllMerchantByPageView() {
        return merchantService.selectAllMerchantByPageView();
    }

    //app-查询具体商海详情
    @GetMapping(value = "/selectMerchantInformation")
    public R selectMerchantInformation(Long id, Long merchantSeaTableId) {
        return merchantService.selectMerchantInformation(id, merchantSeaTableId);
    }
    //app-申请新增信息
    @PostMapping(value = "/addApplyInformation")
    public R addApplyInformation(Long id, Long merchantSeaTableId, String appUserTrueName, String phone, String notes) {
        return merchantService.addApplyInformation(id, merchantSeaTableId, appUserTrueName, phone, notes);
    }

    //app-收藏状态修改
    @PostMapping(value = "/updateCollectStatus")
    public R updateCollectStatus(Long id, Long merchantSeaTableId,Integer collectStatus) {
    return merchantService.updateCollectStatus(id, merchantSeaTableId, collectStatus);
    }

    //app-查询国家对应的商海信息和国家对应的省份
    @GetMapping(value = "/selectAllMerchantAPP")
    public R selectAllMerchantAPP(Long countryId) {
        return merchantService.selectAllMerchantAPP(countryId);
    }

    //app-查询国家和省份对应的商海信息
    @GetMapping(value = "/selectMerchantByCountryIdAndProvinceIdAPP")
    public R selectMerchantByCountryIdAndProvinceIdAPP(Long countryId, Long provinceId) {
        return merchantService.selectMerchantByCountryIdAndProvinceIdAPP(countryId,provinceId);
    }

}
